
    /**  
    * @Title: DBConfigUtils.java
    * @Package com.efast.cafe.framework.utils
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2018年9月19日
    * @version V1.0  
    */
    
package com.efast.cafe.framework.utils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.springframework.util.StringUtils;


/**
    * @ClassName: DBConfigUtils
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2018年9月19日
    *
    */

public class DBConfigUtils {

	private static Properties ConfigProperties = new Properties();
	private static Properties ConfigPubProperties = new Properties();
	
	static {
	   try {
		     ConfigProperties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties"));
		     ConfigPubProperties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("application-public.properties"));
	   } catch (FileNotFoundException e) {
		       e.printStackTrace();
		} catch (IOException e) {
		    	 e.printStackTrace();
	    }
	 }
	
	public static String getDialect(){
		return getValue("cafe.db.dialect");
	}
	
	public static String getDefaultMapperScan(){
		return getValue("mybatis.default.mapper-scan");
	}
	
	public static String getSecondMapperScan(){
		return getValue("mybatis.second.mapper-scan");
	}
	
	
	
	public static String getValue(String key)
    {
		String v = ConfigProperties.getProperty(key);
	    return StringUtils.isEmpty(v)?ConfigPubProperties.getProperty(key):v;
	}
}
